﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>修改学生信息</title>
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <script src="../Scripts/jquery-3.3.1.js"></script>
    <script src="../layui/layui.js" charset="utf-8"></script>
</head>
<body>
    <div class="layui-card">
        <div class="layui-card-header">设置我的资料</div>
        <div class="layui-card-body" pad15="">
          
          <div class="layui-form" lay-filter="">
            <div class="layui-form-item">
             
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">管理员账户</label>
              <div class="layui-input-inline">
                <input type="text" name="teacher_id"  readonly="" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">不可修改</div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">姓名</label>
              <div class="layui-input-inline">
                <input type="text" name="teacher_name" lay-verify="required"  autocomplete="off" placeholder="请输入姓名" class="layui-input">
              </div>
            </div>
            
              
            
            <div class="layui-form-item">
              <label class="layui-form-label">手机</label>
              <div class="layui-input-inline">
                <input type="text" name="teacher_tel" value="" lay-verify="phone" autocomplete="off" class="layui-input">
              </div>
            </div>
           
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" id="submitBtn" >确认修改</button>
               
              </div>
            </div>
          </div>
          
        </div>
      </div>
    <script>
        layui.use(['form', 'layedit', 'layer', 'jquery'], function ()
        {
            var form = layui.form,
                layedit = layui.layedit,
                layer = layui.layer,
                $ = layui.jquery;


          

            $.ajax({
                url: '../operate/getSet.aspx',
                datatype: 'text',
                data: { "table": "tb_teacher" },
                success: function (res)
                {
                    //填充数据
                    var data = res.split(',');
                    $("input[name='teacher_id']").val(data[0]);
                    $("input[name='teacher_name']").val(data[1]);
                    $("input[name='teacher_tel']").val(data[2]);
                }


            });

            $("#submitBtn").click(function ()
            {
                //判断是否为空
                
                if ($("input[name='teacher_name']").val() == "")
                {
                    layer.alert('姓名不能为空');
                    return;
                }
                if ($("input[name='teacher_tel']").val() == "")
                {
                    layer.alert('电话不能为空');
                    return;
                }

                var para = {};
                para["table"] = "tb_teacher";
                var items = $(".layui-input");
                for (var i = 0; i < items.length ; i++)
                {
                    var key = items[i].name;
                    para[key] = items[i].value;
                }
               
                delete para[""];
                $.ajax({
                    url: '../operate/changeAdminInfo.aspx',
                    method:'post',
                    data: para,
                    success: function (res)
                    {
                        if (res > 0)
                        {
                            layer.alert('修改成功', { icon: 1 });
                        }
                        else
                        {
                            layer.alert('修改失败', { icon: 6 });
                        }
                    }

                });
            });

         
        })
    </script>
    
</body>
</html>
